package task3.combo;

import java.beans.EventSetDescriptor;
import java.beans.MethodDescriptor;
import java.beans.ParameterDescriptor;
import java.beans.PropertyDescriptor;
import java.beans.SimpleBeanInfo;
import java.lang.reflect.Method;
import task3.util.InputEvent;
import task3.util.InputListener;

public class BComboBeanInfo
  extends SimpleBeanInfo
{
  public PropertyDescriptor[] getPropertyDescriptors()
  {
    try
    {
      Class<BCombo> cls = BCombo.class;
      PropertyDescriptor operation = new PropertyDescriptor("operation", cls);
      operation.setPropertyEditorClass(OperationEditor.class);
      return new PropertyDescriptor[] { operation };
    }
    catch (Exception ex)
    {
      ex.printStackTrace();
    }
    return null;
  }
  
  public EventSetDescriptor[] getEventSetDescriptors()
  {
    try
    {
      Class<BCombo> c = BCombo.class;
      String es = "input";
      Class<InputListener> lc = InputListener.class;
      String[] names = { "inputChanged" };
      String al = "addListener";
      String rl = "removeListener";
      EventSetDescriptor esd1 = new EventSetDescriptor(c, es, lc, names, al, rl);
      return new EventSetDescriptor[] { esd1 };
    }
    catch (Exception ex)
    {
      ex.printStackTrace();
    }
    return null;
  }
  
  public MethodDescriptor[] getMethodDescriptors()
  {
    try
    {
      Class<BCombo> c = BCombo.class;
      Class[] parameterTypes = new Class[1];
      parameterTypes[0] = InputEvent.class;
      String name = "inputChanged";
      Method method1 = c.getMethod(name, parameterTypes);
      ParameterDescriptor[] pds = new ParameterDescriptor[1];
      pds[0] = new ParameterDescriptor();
      MethodDescriptor md1 = new MethodDescriptor(method1, pds);
      return new MethodDescriptor[] { md1 };
    }
    catch (Exception ex)
    {
      ex.printStackTrace();
    }
    return null;
  }
}
